import lyService from '@/utils/liyuRequest'

// export function obtain(shiTiLeiDH,id,fields) {
//   return request({
//     url: '/record/'+shiTiLeiDH+'/'+id,
//     method: 'post',
//     data:{
//       fields:fields
//     }
//   })
// }
//
// #根据过滤条件、排序条件、分页条件、字段获取实体类集合
// export function search(shiTiLeiDH,filters,sorts,start,limit,fields) {
//   return request({
//     url: '/records/'+shiTiLeiDH+'/'+id,
//     method: 'post',
//     data:{
//       filters:filters,
//       sorts:sorts,
//       start:start,
//       limit:limit,
//       fields:fields
//     }
//   })
// }
//
//

// export function submit(shiTiLeiDH,submitData) {
//   return request({
//     url: '/records/'+shiTiLeiDH,
//     method: 'post',
//     data:submitData
//   })
// }
// #根据实体类代号、id、字段获取一条实体类对象数据

export function obtain(shiTiLeiDH, loadParams) {
  return lyService({
    url: '/record/' + shiTiLeiDH + '/' + loadParams.id,
    method: 'get',
    params: {
      fields: loadParams.fields
    }
  })
}

export function load(shiTiLeiDH, loadParams) {
  return lyService({
    url: '/records/' + shiTiLeiDH,
    method: 'post',
    data: {
      filters: loadParams.filters,
      orders: loadParams.orders,
      start: loadParams.start,
      limit: loadParams.limit,
      fields: loadParams.fields
    }
  })
}

export function search(shiTiLeiDH, filters, sorts, start, limit, fields, id) {
  return lyService({
    url: '/records/' + shiTiLeiDH + '/' + id,
    method: 'post',
    data: {
      filters: filters,
      sorts: sorts,
      start: start,
      limit: limit,
      fields: fields
    }
  })
}
// #向后台提交数据
export function submit(shiTiLeiDH, submitData) {
  return lyService({
    url: '/records/' + shiTiLeiDH,
    method: 'put',
    data: submitData
  })
}
